@extends('layouts.layout')

@section('header')

    <title>我的</title>

    <link rel="stylesheet" type="text/css" href="{{URL::asset('static/css/my.css')}}"/>

@endsection

@section('content')
    <div class="my">
    	<img src="{{ $data['avatar'] }}">
    	<div class="info">
    		<p style="font-weight: bold;">{{ $data['name'] }}</p>
    		<p>{{ $data['phone'] }}</p>
    		@isset($isCode)
                @if($isCode == 1)
                    <p class="invite"><img style="height: .25rem;width: auto;vertical-align: middle;margin-right: .1rem;" src="{{URL::asset('static/img/codeIcon.png')}}" alt="">我的邀请码<img src="{{URL::asset('static/img/right.png')}}" alt=""></p>
                @else
                @endif
            @endisset

    	</div>
    </div>
    <div class="main">
    	<div class="list">
    		<ul>
    			<li>
    				<a href="/my/order">
    					<div>
    						<img src="{{URL::asset('static/img/dingdan.png')}}" >
    						<span>我的订单</span>
    					</div>
    					<img style="height: .27rem;width: auto;" src="{{URL::asset('static/img/right.png')}}" >
    				</a>
    			</li>

                <li>
                	<a href="/my/money">
                		<div>
                			<img src="{{URL::asset('static/img/money.png')}}" >
                			<span>我的余额</span>
                		</div>
                		<img style="height: .27rem;width: auto;" src="{{URL::asset('static/img/right.png')}}" >
                	</a>
                </li>

    			<li>
    				<a href="/user/address">
    					<div>
    						<img src="{{URL::asset('static/img/address.png')}}" >
    						<span>我的地址</span>
    					</div>
    					<img style="height: .27rem;width: auto;" src="{{URL::asset('static/img/right.png')}}" >
    				</a>
    			</li>

                <li>
                    <a href="/my/authentication">
                        <div>
                            <img src="{{URL::asset('static/img/renzheng.png')}}" >
                            <span>实名认证</span>
                        </div>
                        <img style="height: .27rem;width: auto;" src="{{URL::asset('static/img/right.png')}}" >
                    </a>
                </li>

                <li>
                    <a href="/my/invitation">
                        <div>
                            <img src="{{URL::asset('static/img/yq.png')}}" >
                            <span>我的邀请</span>
                        </div>
                        <img style="height: .27rem;width: auto;" src="{{URL::asset('static/img/right.png')}}" >
                    </a>
                </li>

    		</ul>
    	</div>
    </div>

    <div class="footer">
    	<div>
    		<a href="/goods/list">
    			<img src="{{URL::asset('static/img/index.png')}}" alt="">
    			<p>首页</p>
    		</a>
    	</div>
    	<div>
    		<a href="javascript:;">
    			<img src="{{URL::asset('static/img/selMy.png')}}" alt="">
    			<p style="color: #d81e06;">我的</p>
    		</a>
    	</div>
    </div>
    <div id="output" style="display: none;"></div>
@endsection

@section('script')

	<script src="{{URL::asset('static/js/easy.qrcode.js?v=11')}}"></script>

    <script type="text/javascript">

        $(function () {
            $(".toGoods").click(function () {
                var info = $(this).data("info")
                sessionStorage.setItem("goodsInfo", JSON.stringify(info))
                window.location.href = "/goods/detail"
            })

            // 邀请码
            var inviteCode= ""
            // 是否有权限邀请
            commonAjax({type:"post",url:'/my/share'},function(msg){
                inviteCode = msg.code
                // 生成邀请码
                var options = {
                    text: window.location.origin+'/'+inviteCode, // Content
                    width: 240, // Widht
                    height: 240, // Height
                    colorDark: "#000000", // Dark color
                    colorLight: "#ffffff", // Light color
                    logo: "/static/img/ll.png", // LOGO
                    //					logoWidth:80,
                    //					logoHeight:80,

                    quietZone:20,

                    // === Title
                    title: '张三的邀请码',
                    titleFont: "bold 18px Arial",
                    titleColor: "#333",
                    titleBackgroundColor: "#fff",
                    titleHeight: 25,
                    titleTop: 22,

                    logoBackgroundColor: '#ffffff', // Logo backgroud color, Invalid when `logBgTransparent` is true; default is '#ffffff'
                    logoBackgroundTransparent: false, // Whether use transparent image, default is false
                    correctLevel: QRCode.CorrectLevel.H // L, M, Q, H
                }
                new QRCode($("#output").get(0), options);
            })

            $('.invite').click(function(){
                console.log(window.location.origin+'/'+inviteCode)
                if(inviteCode == ""){
                    return false;
                }
                layer.open({
                    anim: 'up'
                    ,content: $("#output").html()
                    ,btn: ['长按或截图分享']
                    ,yes: function(){
                        layer.closeAll()
                    }
                });
            })

        })
    </script>

@endsection
